package com.le.tester.onjava8.l_2_4;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * createTime：2023/2/2 16:39
 * description：简单的可包装类
 */

class IntValue2 {
    public int n;

    public IntValue2(int n) {
        this.n = n;
    }

}

public class SimpleMutableInteger {
    public static void main(String[] args) {
        List<IntValue2> v = IntStream.range(0, 10)
                .mapToObj(IntValue2::new)
                .collect(Collectors.toList());

        //直接调用了n
        v.forEach(iv2 -> System.out.println(iv2.n + " "));

        System.out.println();

        v.forEach(iv2 -> iv2.n += 1);

        //直接调用了n
        v.forEach(iv2 -> System.out.println(iv2.n + " "));
    }
}
